import { fileURLToPath, URL } from 'node:url'

import AutoImport from 'unplugin-auto-import/vite'
import {
    ElementPlusResolver,
    NaiveUiResolver,
} from 'unplugin-vue-components/resolvers'
import Components from 'unplugin-vue-components/vite'
import { defineConfig } from 'vite'

import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import svgLoader from 'vite-svg-loader'

import monacoEditorPlugin from 'vite-plugin-monaco-editor'
import proxyConfig from './proxy.config.ts'
// https://vitejs.dev/config/
export default defineConfig({
    css: {
        preprocessorOptions: {
            scss: {
                api: 'modern-compiler',
                silenceDeprecations: ['legacy-js-api']
            },
        },
    },
    plugins: [
        vue(),
        vueJsx(),
        svgLoader(),
        AutoImport({
            resolvers: [ElementPlusResolver(), NaiveUiResolver()],
        }),
        Components({
            resolvers: [ElementPlusResolver(), NaiveUiResolver()],
        }),
        monacoEditorPlugin({}),
    ],
    server: {
        open: true,
        port: 5176,
        host: '0.0.0.0',
        proxy: proxyConfig.testConfig,
    },
    resolve: {
        alias: {
            '@': fileURLToPath(new URL('./src', import.meta.url)),
        },
    },
})
